/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 19182
 * Date: 2025-08-06
 * Time: 21:24
 */
public class HashBuck2<K, V>{
    static class Node<K, V>{
        public K key;
        public V val;
        public Node<K, V> next;
        public Node(K key, V val){
            this.key = key;
            this.val = val;
        }
    }
    public static final double LOAD_FACTOR = 0.75;  //负载因子的上限
    public Node<K, V>[] array;    //哈希数组
    public int usedSize;
    public HashBuck2(){
        array = (Node<K, V>[])new Node[10];
    }
    public void push(K key, V val){
        int index = hashCode() % array.length;
        Node<K, V> cur = array[index];
        while(cur != null){
            if(cur.key.equals(key)){
                cur.key = key;
                return;
            }
            cur = cur.next;
        }
        Node<K, V> node = new Node<K, V>(key, val);
        node.next = array[index];
        array[index] = node;
        usedSize++;
    }
}
